<script>
import { mapActions, mapMutations, mapState } from 'vuex';
import request from '@/utils/request';
import $ from 'jquery'
export default {
	data(){
		return{
			 
		}
	},
	computed: {
		...mapState(['lang']),
		
		
	},
	created() {
		
	},
	onShow() {
		let that = this;
		that.getNowPrice1();
		that.getNowPrice2();
		that.getNowPrice3();
		that.getNowPrice4();
		that.getNowPrice5();
		setInterval(() => {
			that.getNowPrice1();
			that.getNowPrice2();
			that.getNowPrice3();
			that.getNowPrice4();
			that.getNowPrice5();
		}, 5000);
	},
	onLaunch() {
		
		

		// 从Storage获取登录和用户信息，缓存到vuex
		let _self = this;
		// debugger
		uni.getStorage({
			key: 'userinfo',
			success: function(data) {
				// _self.changeLoginStatus(data.data.SessionId!=undefined);
				_self.$store.commit('user/LOGIN_INFO', data.data);
			}
		});
		

	},
	methods: {
		
		

		// 获取最新价格
		getNowPrice1() {
			var that = this;
			function callbackparam(res) {}
			$.ajax({
				type: 'GET',
				url: 'https://line.dupont-ex.com/getdatahis.ashx',
				contentType: 'application/json',
				data: {
					symbol: that.list[0],
					type: 'today'
				},
				async: false,
				dataType: 'jsonp',
				jsonp: 'callbackparam',
				success: function(data) {
					// console.log(data.TodayClosePrice);
					that.$store.commit('BTCUSDT', data.TodayClosePrice);
				}
			});
		},
		getNowPrice2() {
			var that = this;
			function callbackparam(res) {}
			$.ajax({
				type: 'GET',
				url: 'https://line.dupont-ex.com/getdatahis.ashx',
				contentType: 'application/json',
				data: {
					symbol: that.list[1],
					type: 'today'
				},
				async: false,
				dataType: 'jsonp',
				jsonp: 'callbackparam',
				success: function(data) {
					// console.log(data.TodayClosePrice);
					that.$store.commit('ETHUSDT', data.TodayClosePrice);
				}
			});
		},
		getNowPrice3() {
			var that = this;
			function callbackparam(res) {}
			$.ajax({
				type: 'GET',
				url: 'https://line.dupont-ex.com/getdatahis.ashx',
				contentType: 'application/json',
				data: {
					symbol: that.list[2],
					type: 'today'
				},
				async: false,
				dataType: 'jsonp',
				jsonp: 'callbackparam',
				success: function(data) {
					// console.log(data.TodayClosePrice);
					that.$store.commit('LTCUSDT', data.TodayClosePrice);
				}
			});
		},
		getNowPrice4() {
			var that = this;
			function callbackparam(res) {}
			$.ajax({
				type: 'GET',
				url: 'https://line.dupont-ex.com/getdatahis.ashx',
				contentType: 'application/json',
				data: {
					symbol: that.list[3],
					type: 'today'
				},
				async: false,
				dataType: 'jsonp',
				jsonp: 'callbackparam',
				success: function(data) {
					// console.log(data.TodayClosePrice);
					that.$store.commit('HS300USDT', data.TodayClosePrice);
				}
			});
		},
		getNowPrice5() {
			var that = this;
			function callbackparam(res) {}
			$.ajax({
				type: 'GET',
				url: 'https://line.dupont-ex.com/getdatahis.ashx',
				contentType: 'application/json',
				data: {
					symbol: that.list[4],
					type: 'today'
				},
				async: false,
				dataType: 'jsonp',
				jsonp: 'callbackparam',
				success: function(data) {
					// console.log(data.TodayClosePrice);
					that.$store.commit('IC500USDT', data.TodayClosePrice);
				}
			});
		},

		async getLocation() {
			return await new Promise((resolve, reject) => {
				wx.getLocation({
					success(location) {
						resolve(location);
					},
					fail(err) {
						reject(err);
					}
				});
			});
		}
	}
};
</script>

<style>
/* uni.css - 通用组件、模板样式库，可以当作一套ui库应用 */
@import './common/uni.css';

[v-cloak] {
	display: none;
}
/* 自定义的通用文件 */
.undisButton {
	background: linear-gradient(-90deg, rgba(104, 129, 255, 1), rgba(115, 156, 255, 1)) !important;
}
.uni-body.pages-c2c-pay {
	background-color: #f7f7fb;
}
html,
body {
	overflow: hidden;
	height: 100%;
	background: #ffffff;
}

.container {
	font-size: $font-base;
	overflow: hidden;
}

.wrapper {
	font-size: $font-base;
	text-align: left;
}

* {
	transition: width 2s;
	-moz-transition: width 2s;
	-webkit-transition: width 2s;
	-o-transition: width 2s;
}

/* font color */

.gray {
	color: #808080;
}

.wxParse {
	text-indent: 2em;
}

.wxParse image {
	text-indent: 0;
}

.wxParse ._view {
	padding: 0 10rpx;
	text-indent: 0;
}

.wxParse .p {
	text-indent: 1em;
}
.page-head-title {
	font-size: 38upx;
	font-family: PingFang-SC-Bold;
	font-weight: bold;
	color: rgba(38, 37, 80, 1);
	margin-left: 30upx;
}
.page-container {
	/* #ifdef APP-PLUS */
	padding-top: calc(96upx + var(--status-bar-height));
	/* #endif */
	/* #ifndef APP-PLUS */
	padding-top: calc(96upx);
	/* #endif */
}
</style>
